<?php // I know the syntax is probably wrong, or not optimised, but I'm still learning >_>" #Tom

//Set up MySQL connection so procedures can be called
$dbase = new mysqli('localhost', 'root', 'password', 'sourcedrop');


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
<link rel='StyleSheet' HREF="CSS.css" TYPE="text/css">
	<title>//SourceDrop</title>
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>

<body>

<div id='header'>

    <img src="images/sourcedrop.png"></img>

</div>



<div id='body'>

    <p>Fillertext2</p>
	<br />
	
	<!--Form. Submits form box data as $_POST['formInput']-->
	<!-- changed target='' to action='', this way the browser doesnt open in a new tab, it'll just refresh on to itself - JD 8/8/11 -->
	<form action="index_v2.php" method="post"> 
	Submit:<input type="text" name="formInput" /><input type="submit" />
	</form>
	
	<!--Form that submits the ID of the data to be returned. $POST_['formID']-->
	<form action="index_v2.php" method="post">
	Retrieve:<input type="text" name="formID" /><input type="submit" />
	</form>

</div>



<div id='return'>

<?php //The php block for inserting $_Post['formIput'] into the SQL server.

if(empty($_POST['formInput'])){
	echo 'POST is empty!' . '<br />';
	}
	else
	{
	//Errors occur in MySQL->query INSERT. It doesn't like being passed $_POST arrays, but variables are okay.
	$postInput = $_POST['formInput'];
	
	//SQL Query code
			$dbase->query("INSERT INTO myTable VALUES ('', '$postInput')") or die($dbase->error);
	}

?>

<?php //Display ALL SQL database entries and their ID (Just for dev purposes)

//Get all primary indexes and associated data(text column)
$resultData = $dbase->query('SELECT * FROM myTable') or die($mysql->error);

//While there's a row to read, read it and set $row to it.
while($rowData = $resultData->fetch_object()){

//Echo database current row 'id' column
echo $rowData->id . ' ';

//Echo database current row 'data' column
echo $rowData->data . '<br />';

}
?>

<?php //Retrieve data based on input ID from $_POST['formID']

// Added this if statement, to make sure that we're always getting a form post called 'formID' before executing anything below - JD 8/8/11
if(!empty($_POST['formID']))
{

//put $_POST['formID'] into a variable
$postID = $_POST['formID'];

//Get all primary indexes and associated data(text column)
$resultID = $dbase->query("SELECT * FROM myTable WHERE id=$postID") or die($mysql->error);

//Echo database current row 'data' column
$rowID = $resultID->fetch_object();
echo '<br />' . $rowID->id . ': ';
echo $rowID->data;

}

/*
Notes:

Okay, so this is the error I think you're getting? Either way lets debugging it!!!

Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\xampp\htdocs\dev\index_v2.php on line 96

Firstly, PHP 'most' the time gives you decent errors, and should tell you what your doing wrong and where. So here lets look at line 96.
Line 96, echo $resultID .... we're anticipating a string to echo out to the screen, so lets see where $resultID is set. 
Line 93, we set $resultID, but from $dbase->query()... firstly are we sure that this method returns a string? most cases the database return an array or object
So I think we might be getting something other than a string, lets change Line 96 instead of echo lets do print_r($resultID);
Awesome, we got something better...

mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 1 [type] => 0 )

So we're getting an object result set. The best way to work out what to do next is to do some googling, see how to handle printing out results that are an object. 
I've reverted my changes, I'll let you trail n error with it ;) ... a quick hint

echo $resultID->num_rows 
This code will return: 1

*/ 

?>
</div>

</body>

</html>